<?php $this->JQuery()->addJavascriptFile('http://bp.yahooapis.com/2.4.21/browserplus-min.js')?>

<?php $this->JQuery()->addJavascriptFile(Ac_Util::getImageBaseUrl('/js/plupload/plupload.v-'.AC_VERSION.'.js'))?>
<?php $this->JQuery()->addJavascriptFile(Ac_Util::getImageBaseUrl('/js/plupload/plupload.html5.v-'.AC_VERSION.'.js'))?>
<?php $this->JQuery()->addJavascriptFile(Ac_Util::getImageBaseUrl('/js/plupload/plupload.html4.v-'.AC_VERSION.'.js'))?>
<?php $this->JQuery()->addJavascriptFile(Ac_Util::getImageBaseUrl('/js/plugins.js'))?>

<?php $this->JQuery()->addJavascriptFile(Ac_Util::getImageBaseUrl('/js/plupload/jquery.plupload.queue.min.v-'.AC_VERSION.'.js'))?>
<?php if (IS_LIVE):?>
    <?php $this->headLink()->appendStylesheet(Ac_Util::getImageBaseUrl('/css/plupload/plupload.queue.v-'.AC_VERSION.'.css'))?>
<?php endif;?>

<?php 
    if (!empty($this->listing)) {
        $type = 'listing';
    } elseif(!empty($this->user)) {
        $type = 'user';
    } else {
        $type = '';
    }
?>

<?php $this->JQuery()->javascriptCaptureStart()?>
$(function() {
    $j('.al-piclist img').live('click', function(){
		if($j(this).parent().parent().parent().hasClass('cur'))
		{
			$j(this).parent().parent().parent().removeClass('cur');
			$j(this).parent().find('input[type="hidden"]').remove();
		}else{
			$j(this).parent().parent().parent().addClass('cur');
			$j(this).parent().append('<input type="hidden" name="ph[]" value="'+$j(this).attr('src')+'">');
		}
	});
	
	$j('#file_upload_1_btn').click(function(){
		if($j('.remove_photo').size() <= 0){
			$j('#file_upload_1').click();
		}
	});
	
	$j('.remove_photo').click(function() {
        var nb = $(this).attr('rel');
        $j.post(
            <?php if (!empty($this->listing)):?>
               '<?php echo $this->geturl('delete-photo','listing')?>',
            <?php elseif (!empty($this->company)):?>
               '<?php echo $this->geturl('delete-photo','user')?>',
            <?php endif;?>
            {adid:$j('#adid').attr('value'), num:nb},
            function (data) {
                $('#photo'+nb).remove();
                $('#profile_pic_cnt').attr("rel", parseInt($('#profile_pic_cnt').attr("rel")) - 1);
                var i = 0;
                $('.remove_photo').each(function() {
                    $(this).attr('rel', i++);
                });                
                var i = 0;
                $('.feature_photo').each(function() {
                    $(this).attr('rel', i++);
                });		                               
            }
        );
       
        return false;
    });
    
    $j('.pic_resize').picPortionResize({
		maxWidth: 200,
		maxHeight: 160
	}).show();
});
<?php $this->JQuery()->javascriptCaptureEnd()?>
<div class="detail" style="height: 180px;">
<div class="al-updv photo_uploader">
	<div style="position:absolute; top: 0px; left: 10px; border:0px solid red;">
		<?php
	        $photos = array();
	        if (!empty($this->listing)) {
	            $photos = $this->listing->photos;
	        }
	    ?>
		 <div rel="<?php echo count($photos)?>" id="profile_pic_cnt" style="">
	    	<input type="hidden" name="adid" id="adid" value="<?php echo $this->adid?>">
	        <?php if(empty($photos)):?>
	    	    <p id="no_photo_selected">没有选定图片</p>
	        <?php else:?>
		        <?php foreach($photos as $k => $photo):?>
		            <div id="photo<?php echo $k?>">
	                    <img style="display: none;" class="pic_resize" src="<?php //echo $this->thumbnail()->scale($photo, 150, 150);
	                    				echo Ac_Util::getImageBaseUrl('/images/photo/original') . $photo . '?random=' . rand(0, 99999); ?>">
						<a href="#" id="remove_photo_0" class="remove_photo" rel="<?php echo $k?>">移除</a>
		            </div>
		        <?php endforeach;?>
	        <?php endif;?>
	    </div>
	</div>
	<a class="abtn abtn-i dib al-upbtn" href="javascript:;" id="al-upbtn" style="background-position: -4px -120px;">
		<u>
			<label id="file_upload_1_btn">上传图片</label>
		</u>
		<form style="display: none;" action="<?php echo $this->geturl('upimglocal', 'listing', null, 'default'); ?>" method="POST" id="listing_form"  enctype="multipart/form-data">
			<input type="file" hidefocus="true"  id="file_upload_1" name="upload1" style="left: 175.5px; top: 65px;">
			<?php $this->JQuery()->javascriptCaptureStart() ?>
                $j('#file_upload_1').change(function(){
                	$(this).parent('form').submit();
                });
			<?php $this->JQuery()->javascriptCaptureEnd() ?>
		</form>
	</a>
</div>
<div class="al-size gray">
		· 你只能上传一张图片
		<br>
		· 仅支持JPEG、JPG、PNG或TIF图片格式 
		<br>
		· 文件要小于4M 
		<br>
		· 图片分辨率要大于80x80 
		<br>
		· 如果有图片来源，
		<br>
		· 请务必标注来源和原创作者
</div>
</div>